//提现时分析师未认证判断
$(function(){
    if(type == 'cardauth'){
        $('.sanjiao').css('background-image','url(../../images/toright.png)');
        $('.sanjiao:eq(3)').css('background-image','url(../../images/toRightChoice.png)');
        $('.r_left>li:eq(3)').addClass("a_color").siblings().removeClass("a_color");
        $(".pic4 img").attr('src','../../images/renzhengSelected.png');
        $(".pic1 img").attr('src','../../images/touxiang.png');
        $(".pic2 img").attr('src','../../images/zhanghuSave.png');
        $(".pic3 img").attr('src','../../images/chongzhi.png');
        $('.r_right li:eq(0)').css('display','none');
        $('.r_right li:eq(3)').css('display','block');
        //定位到分析师认证
        $('.r_left > li').siblings().removeClass('active');
        $('.r_left > li').eq(3).addClass('active');
        $('.r_left > li').eq(3).find('img').attr('src','../../images/baise.png');
    }else if(type == "recomm"){
        $('.sanjiao').css('background-image','url(../../images/toright.png)');
        $('.sanjiao:eq(3)').css('background-image','url(../../images/toRightChoice.png)');
        $('.r_left>li:eq(3)').addClass("a_color").siblings().removeClass("a_color");
        $(".pic4 img").attr('src','../../images/renzhengSelected.png');
        $(".pic1 img").attr('src','../../images/touxiang.png');
        $(".pic2 img").attr('src','../../images/zhanghuSave.png');
        $(".pic3 img").attr('src','../../images/chongzhi.png');
        $('.r_right li').css('display','none');
        $('.r_right li:eq(4)').css('display','block');
        //定位到分析师认证
        $('.r_left > li').siblings().removeClass('active');
        $('.r_left > li').eq(4).addClass('active');
        $('.r_left > li').eq(4).find('img').attr('src','../../images/baise.png');
    }else {
        $('.sanjiao:eq(0)').css('background-image','url(../../images/toRightChoice.png)');
    }
})
// 分析师我的资料tab切换
$(function(){
        var renZheng_li=$('.renZheng>ul>li');
        var main_li=$('.r_right>ul>li');
        for(var i=0; i<renZheng_li.length; i++){
            renZheng_li[i].setAttribute('index',i);
            renZheng_li[i].onclick=function(){
                for(var j=0; j<renZheng_li.length; j++) {
                    renZheng_li[j].removeAttribute('class');
                }
                this.setAttribute('class','active');

                for(k=0; k<main_li.length; k++) {
                    main_li[k].style.display='none';
                }
                this.style.display='block';
                main_li[this.getAttribute('index')].style.display='block';
            }
        }
})

// 我的资料上传身份证件
//身份证正面
$(function (e) {
    $("#uploadzhengForm").on('submit', function(e){
        e.preventDefault();
        $.ajax({
            url: imgurl,
            type: "POST",
            data:  new FormData(this),
            headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
            contentType: false,
            cache: false,
            processData: false,
            // 显示加载图片
            beforeSend: function () {
                $('.loading-shadow').addClass('active');
            },
            success: function (data) {
                if(data.status == 1) {
                    $('#img1').attr('src', data.msg);
                    $('#idcardimg').attr('value', data.msg);
                }else{
                    layer.tips(data.msg,'#img1',{time:1000});
                }
            },
            error: function(){}
        });
    });
});
//身份证反面
$(function (e) {
    $("#uploadfanForm").on('submit', function(e){
        e.preventDefault();
        $.ajax({
            url: imgurl,
            type: "POST",
            data:  new FormData(this),
            headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
            contentType: false,
            cache: false,
            processData: false,
            // 显示加载图片
            beforeSend: function () {
                $('.loading-shadow').addClass('active');
            },
            success: function (data) {
                if(data.status == 1){
                    $('#img2').attr('src',data.msg);
                    $('#idcardimgf').attr('value',data.msg);
                }else{
                    layer.tips(data.msg,'#img2',{time:1000});
                }
            },
            error: function(){}
        });
    });
});
$(function(){
        // 认证页面上传正面身份证
        var frontBox = document.querySelector("#frontBox");
        var front_icon = document.querySelector("#front_icon");
        frontBox.onclick = function(){
            front_icon.click();     //file1触发事件
        }
        var myFile;
        front_icon.onchange = function(){     //当事件改变的时候触发
            // 获取上传文件的大小
            var file_size=parseInt((document.getElementById('front_icon').files[0].size)/1024/1024)
            if(file_size <= 2) {
                $("#uploadzhengForm").trigger('submit');
            }else{
                layer.tips('图片大小不能超过2M!','#img1',{time:1000});
            }
        }

       //认证页面上传反面身份证
        var backBox = document.querySelector("#backBox");
        var back_icon = document.querySelector("#back_icon")   
        backBox.onclick = function(){
            back_icon.click();     //file1触发事件
        }
        var myFile;
        back_icon.onchange = function(){     //当事件改变的时候触发
            var file_size=parseInt((document.getElementById('back_icon').files[0].size)/1024/1024)
            if(file_size <= 2) {
                $("#uploadfanForm").trigger('submit');
            }else{
                layer.tips('图片大小不能超过2M!','#img2',{time:1000});
            }
        }

})

$('#r_name').keyup(function(){
    $('#l_tishi').html("请输入2~6位中文字符!");
})
$('#r_name').blur(function(){
    var username    = $.trim($('#r_name').val());
    var isChinaName=/^[\u4E00-\uFA29]|[\uE7C7-\uE7F3]{2,6}$/;
    var usernamereg=isChinaName.test(username);
    if(usernamereg){
        $('#l_tishi').html("");
    }
})
function doauth(){
    var idcardimg   = $.trim($('input[name=idcardimg]').val());
    var idcardimgf  = $.trim($('input[name=idcardimgf]').val());
    var username    = $.trim($('#r_name').val());
    var idcard      = $.trim($('#r_num').val());
    var img1 = $('#img1').attr('src');
    var img2 = $('#img2').attr('src');
    var isChinaName=/^[\u4E00-\uFA29]|[\uE7C7-\uE7F3]{2,6}$/;
    var isIDCard2 = isCreditNo(idcard);
    if(idcard == '' && username == '') {
        layer.tips('请输入中文姓名和有效身份证号!','#r_name',{time:1000});
        return;
    }else if(username == '') {
        layer.tips('请输入中文姓名!','#r_name',{time:1000});
        return;
    }else if(idcard == '') {
        layer.tips('请输入身份证号!','#r_num',{time:1000});
        return;
    }else if(!isIDCard2) {
        // 身份证号不正确
        layer.tips('请输入有效身份证号!','#r_num',{time:1000});
        return;
    }else if(!isChinaName.test(username)) {
        // 姓名不正确
        layer.tips('请输入中文姓名!','#r_name',{time:1000});
        return;
    }else if(!isIDCard2 && !isChinaName.test(username)) {
        layer.tips('请输入中文姓名和有效身份证号!','#r_name',{time:1000});
        return;
    }else if(idcardimg == "") {
        layer.tips('请上传身份证!','#img1',{time:1000});
        return;
    }else if(idcardimgf == "") {
        layer.tips('请上传身份证!','#img2',{time:1000});
        return;
    }
    $.ajax({
        url:cardauth,
        type: 'post',
        data: {'idcardimg':idcardimg,'idcardimgf':idcardimgf,'username':username,'idcard':idcard},
        headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
        dataType:'json',
        success: function(res){
            if(res.status == 0){
                if(type == 'cardauth'){
                    window.location.href = docashurl;
                }else{
                    $('.r_info_top').hide();
                    $('.r_success').show();
                }
            }else if(res.status == 3){
                if(type == 'cardauth'){
                    window.location.href = docashurl;
                }else{
                    $('.r_info_top').hide();
                    $('.r_success').show();
                }
            }else if(res.status == 1){
               layer.tips(res.msg,'#r_name',{time:1000});
            }
        }
    });
}
    function isCreditNo(vStr){
        var vCity = [
            '11','12','13','14','15','21','22',
            '23','31','32','33','34','35','36',
            '37','41','42','43','44','45','46',
            '50','51','52','53','54','61','62',
            '63','64','65','71','81','82','91'
        ];
        var reg = /^([\d]{17}[xX\d]|[\d]{15})$/;
        if (!(reg.test(vStr))) return false;
        if ($.inArray(vStr.substr(0, 2), vCity) == -1) return false;
        vStr = vStr.replace(/[xX]$/i, 'a');
        var vLength = vStr.length;
        var vBirthday;
        if (vLength == 18) {
            vBirthday = vStr.substr(6, 4) +'-' +vStr.substr(10, 2) + '-' + vStr.substr(12, 2);
        } else {
            vBirthday = '19' + vStr.substr(6, 2) + '-' + vStr.substr(8, 2) + '-' + vStr.substr(10, 2);
        }
        //if (date('Y-m-d', strtotime(vBirthday)) != vBirthday) return false;
        if (vLength == 18) {
            var vSum = 0;
            for ( var i = 17 ; i >= 0 ; i--) {
                var vSubStr = vStr.substr(17 - i, 1);
                vSum += ( Math.pow(2, i) % 11) * ((vSubStr == 'a') ? 10 : parseInt(vSubStr , 11));
            }
            if(vSum % 11 != 1) return false;
        }
        return true;
    }
//学历提交
function doschoole(){
   var diplomas =  $('input[name=diplomas]').val();
   var school   =  $('input[name=school]').val();
    if(diplomas == ''){
        layer.tips('请输入学历!','#diplomas',{time:1000});
        return;
    }else if(school == ''){
        layer.tips('请输入毕业院校!','#school',{time:1000});
        return;
    }
    $.ajax({
        url:schoolurl,
        type: 'post',
        data: {'diplomas':diplomas,'school':school},
        headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
        dataType:'json',
        success: function(res){
            if(res.status == 0){
                //学历提交成功
                $('.r_stuInfo').hide();
                $('.r_stuinfo_success').show();  
                $('#diplomasshow').text(res.diplomas);   
                $('#schoolshow').text(res.school);      
            }else if(res.status == 3){
                //学历修改成功
                $('.r_stuInfo').hide();  
                $('.r_stuinfo_success').show();  
                $('#diplomasshow').text(res.diplomas);   
                $('#schoolshow').text(res.school);   
            }
        }
    });
}
//重新填写
function updateauth(){
    $('.r_info_top').show();
    $('.r_success').hide();
    $('#idcardimg').attr('value','');
    $('#idcardimgf').attr('value','');
    $('input[name=username]').val('');
    $('input[name=idcard]').val('');
    $('#img1').attr('src','/images/rect1.png');
    $('#img2').attr('src','/images/rect1.png');
    //$('#r_name').attr('value','');
    //$('#r_num').attr('value','');
}
function updatestu(){
    $('.r_stuInfo').show();
    $('.r_stuinfo_success').hide();
    $('#diplomas').val($('#diplomasshow').html());
    $('#school').val($('#schoolshow').html());
}
// 提现tab切换
$(function(){
        var sub_li=$('.cash_sub>ul>li');
        var main_li=$('.cash_main>ul>li');
        for(var i=0; i<sub_li.length; i++){
            sub_li[i].setAttribute('index',i);
            sub_li[i].onclick=function(){
                for(var j=0; j<sub_li.length; j++) {
                    sub_li[j].removeAttribute('class');
                }
                this.setAttribute('class','current');

                for(k=0; k<main_li.length; k++) {
                    main_li[k].style.display='none';
                }
                this.style.display='block';
                main_li[this.getAttribute('index')].style.display='block';
            }
        }
})
// 左侧切换
$(function(){
    // $('.sanjiao:eq(0)').css('background-image','url(../../images/toRightChoice.png)');
    var lis=$('.r_left>li');
    lis.click(function(){
        $(this).addClass("a_color").siblings().removeClass("a_color");
        $('.sanjiao').css('background-image','url(../../images/toright.png)');
        $(this).children().children('.sanjiao').css('background-image','url(../../images/toRightChoice.png)');
        var index = $(this).index();
        if(index == 0) {
            $(".pic1 img").attr('src','../../images/touxiangSelected.png');
            $(".pic2 img").attr('src','../../images/zhanghuSave.png');
            $(".pic3 img").attr('src','../../images/chongzhi.png');
            $(".pic4 img").attr('src','../../images/renzheng.png');
            $(".pic5 img").attr('src','../../images/huise.png');
            $(".pic6 img").attr('src','../../images/history.png');
        }else if(index == 1) {
            $(".pic2 img").attr('src','../../images/zhanghuSaveSelected.png');
            $(".pic1 img").attr('src','../../images/touxiang.png');
            $(".pic3 img").attr('src','../../images/chongzhi.png');
            $(".pic4 img").attr('src','../../images/renzheng.png');
            $(".pic5 img").attr('src','../../images/huise.png');
            $(".pic6 img").attr('src','../../images/history.png');
        }else if(index == 2) {
            $(".pic3 img").attr('src','../../images/chongzhiSelected.png');
            $(".pic2 img").attr('src','../../images/zhanghuSave.png');
            $(".pic1 img").attr('src','../../images/touxiang.png');
            $(".pic4 img").attr('src','../../images/renzheng.png');
            $(".pic5 img").attr('src','../../images/huise.png');
            $(".pic6 img").attr('src','../../images/history.png');
        }else if(index == 3) {
            $(".pic4 img").attr('src','../../images/renzhengSelected.png');
            $(".pic1 img").attr('src','../../images/touxiang.png');
            $(".pic2 img").attr('src','../../images/zhanghuSave.png');
            $(".pic3 img").attr('src','../../images/chongzhi.png');
            $(".pic5 img").attr('src','../../images/huise.png');
            $(".pic6 img").attr('src','../../images/history.png');
        }else if(index == 4) {
            $(".pic5 img").attr('src','../../images/baise.png');
            $(".pic4 img").attr('src','../../images/renzhengSelected.png');
            $(".pic1 img").attr('src','../../images/touxiang.png');
            $(".pic2 img").attr('src','../../images/zhanghuSave.png');
            $(".pic3 img").attr('src','../../images/chongzhi.png');
            $(".pic6 img").attr('src','../../images/history.png');
        }else if(index == 5) {
            $(".pic6 img").attr('src','../../images/historyed.png');
            $(".pic5 img").attr('src','../../images/huise.png');
            $(".pic4 img").attr('src','../../images/renzheng.png');
            $(".pic1 img").attr('src','../../images/touxiang.png');
            $(".pic2 img").attr('src','../../images/zhanghuSave.png');
            $(".pic3 img").attr('src','../../images/chongzhi.png');
        }
    })
})


// 收起按钮
function shouBtn1(){
    $('.r_info').slideToggle(function(){
        if ($(this).is(':hidden')) {
            $("#sanjiao1").html("展开<img src='../../images/kai.png' style='margin-left:8px;'>");
        }else{
            $("#sanjiao1").html("收起<img src='../../images/shou.png' style='margin-left:8px;'>");
        }
    });
}
function shouBtn2(){
    $('.r_xueli').slideToggle(function(){
        if ($(this).is(':hidden')) {
            $("#sanjiao2").html("展开<img src='../../images/kai.png' style='margin-left:8px;'>");
        }else{
            $("#sanjiao2").html("收起<img src='../../images/shou.png' style='margin-left:8px;'>");
        }
    });
}








/*  201-05-08 基本信息  展开收起事件开始超  */
//头像上传
$(function (e) {
    $("#photo_up").on('submit', function(e){
        e.preventDefault();
        $.ajax({
            url: imgurl,
            type: "POST",
            data:  new FormData(this),
            headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
            contentType: false,
            cache: false,
            processData: false,
            // 显示加载图片
            beforeSend: function () {
                $('.loading-shadow').addClass('active');
            },
            success: function (data) {
                if(data.status == 1){
                    $('#j_tx').attr('value',data.msg);
                    $('#photo').attr('value',data.msg);
                    $('#photoshow').attr('src',data.msg);
                }else{
                    layer.tips(data.msg,'#j_img',{time:1000});
                }
            },
            error: function(){}
        });
    });
});
$(function(){
	// 展开收起
	$('#j_open').click(function(){
        var self = $(this);
        $('#j_Essential_content').slideToggle(function(){
            if ($(this).is(':hidden')) {
                self.html("展开<img src='../../images/kai.png' style='margin-left:5px;'>");
            }else{
                self.html("收起<img src='../../images/shou.png' style='margin-left:5px;'>");
            }
        });
	})
	
	$('#j_open_two').click(function(){
        $('#j_Essential_content_right').slideToggle(function(){
            if ($(this).is(':hidden')) {
                $("#sanjiao4").attr('src','../../images/kai.png');
                $("#kaiqi4").html("展开");
            }else{
                $("#sanjiao4").attr('src','../../images/shou.png');
                $("#kaiqi4").html("收起");
            }
        });
	})
	
	// 头像上传
    var obj = document.querySelector("#j_heade_up"),
		file1 = document.querySelector("#j_tx"),
		j_img = document.querySelector('#j_img');
	obj.onclick = function(){
		file1.click();     //file1触发事件
	}
	var files;
	file1.onchange = function(){     //当事件改变的时候触发
        var file_size=parseInt(document.getElementById('j_tx').files[0].size/1024/1024)
        if(file_size <= 2) {
            $("#photo_up").trigger('submit');
        }else{
            layer.tips('图片大小不能超过2M!','#j_img',{time:1000});
        }
	}
	
	// 默认图片
	var j_content_right = $('#j_content_right'),
		j_img_n =  $('#j_content_right img');
	for(var i =0;i<j_img_n.length;i++){
		j_img_n[i].onclick = function(){
            $('#photoshow').attr('src',this.src);
            $('#photo').attr('value',this.src);
		}
	}
	
	// 下拉框
$('.flui_selectBox').hover(function() {
	$(this).find('.flui_opList').addClass('flui_opList_show');
	$(this).find('.arrow_btn').addClass('arrow_btn_u');
}, function() {
	$(this).find('.flui_opList').removeClass('flui_opList_show');
	$(this).find('.arrow_btn').removeClass('arrow_btn_u');
})

$('.city_flui_opValue').bind('click', function() {
	$(this).parents('.flui_selectBox').find('.flui_opSlValue').text($(this).text());
	$(this).parents('.flui_selectBox').find('.flui_opSlValue').attr('value', $(this).attr('value'));
});

$('.flui_radioBox').click(function() {
	$(this).addClass('flui_radioBox_ck').siblings().removeClass('flui_radioBox_ck');
});
       

// 基本信息    
$("#redIntroductionMsg").hide();
$("#redNameMsg").hide();

$("#btnCancelUD").click(function() {
	$("#IntroductionValue").val("");
	$("#redIntroductionMsg").hide();
});
loadDateTimePicker()

function loadDateTimePicker() {
	$(".laydate-icon").each(function(index, el) {
		var id = $(el).attr('id');
		laydate.skin('molv');
		$(el).click(function(event) {
			laydate({
				elem: '#' + id,
				isclear: false,
				choose: function(datas) {
					if(window['on_search'] != undefined) {
						window['on_search'](id);
					}
				}
			});
		});
	});
}

var end = {
	elem: '#OStartTime',
	max: laydate.now(),
	istoday: true,
};
laydate.skin('molv');
laydate(end);

$(".provincesflui_opValue").click(function() {
	$(this).parents('.flui_selectBox').find('.flui_opSlValue').text($(this).text());
	$(this).parents('.flui_selectBox').find('.flui_opSlValue').attr('value', $(this).attr('value'));
	var value = $(this).attr('value');
	$("#citys").html("");
	$.ajax({
		type: "POST",
		data: { code: value },
		url: "/Account/UserInfo/GetCityList"
	}).success(function(data) {
		$("#citys").html("");
		var resultHtml = "";
		$("#cityList").attr('value', "0");
		$("#cityList").html("");
		for(var i = 0; i < data.length; i++) {
			resultHtml += "<li><a href='javascript:;' class='city_flui_opValue' value='" + data[i].Value + "'>" + data[i].Text + "</a></li>";
		}
		$("#cityList").attr('value', data[0].Value);
		$("#cityList").html(data[0].Text);
		$("#citys").html(resultHtml);
	});
});

    var tiyan = '{{ $tiyan }}';
    var maxtime = tiyan*60*60*24; //15天的秒数
    // var maxtime = 15;
    var timer; 
    function CountDown(){ 
        clearInterval(timer);
        if(maxtime>=0){ 
            // 剩余天数
            var day = Math.floor(maxtime/ 60 / 60 / 24);
            //剩余小时
            var hours = Math.floor(maxtime/ 60 / 60 % 24);
            //剩余分钟数
            var minutes = Math.floor(maxtime % 3600 / 60); 
            var seconds = Math.floor(maxtime % 60); 
            var msg = "<span style='font-size:12px;'>体验账户倒计时： </span>"+"<span style='font-size:14px;'>"+day+"</span>"+"<span style='font-size:12px;'>天</span>"+"<span style='font-size:14px;'>" +hours+"</span>"+"<span style='font-size:12px;'>小时</span>" +"<span style='font-size:14px;'>"+minutes+"</span>"+"<span style='font-size:12px;'>分</span>"; 
            $('#aBox').html(msg); 
            --maxtime; 
            }else{ 
            clearInterval(timer); 
            //一下两个方法是倒计时结束后调用的方法 
            $('#aBox').html('您的体验已结束,"<a style="font-size:14px;color:#f6a405;">请充值！</a>'); 
            searchTaskList(); 
            myajax(); 
            //设置下一次的倒计时 
            //maxtime=7*60*60*24; 
            timer=setInterval("CountDown()",1000); 
        } 
    } 
$("#email").blur(function(){
	var regex = /^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;
	var email_l = $.trim($("#email").val());
	if(email_l === '' || !(regex.test(email_l))){
        $('.j_email_l').html('请输入合法的邮箱地址!');
        $('.j_email_l').css('color','#00A8EE')
	}else{
		$('.j_email_l').html('');
	}
})
var nameReg = /^[\u4e00-\u9fffa-zA-Z]{3,6}$/;
$("#username").blur(function(){
    var username = $.trim($("#username").val());
    if(username.indexOf('毅思') >= 0){
        $('#usernametishi').html('该用户名已存在!');
        $('#usernametishi').css('color','#00A8EE')
    }else if(username === '' || !(nameReg.test(username))){
        $('#usernametishi').html('请输入3~6位字符!');
        $('#usernametishi').css('color','#00A8EE');
        return ;
    }else{
        checkname(username);
    }
})
var flag = false;
//验证用户名
function checkname(username){
    $.ajax({
        url:posturl,
        type: 'post',
        data: {username:username,type:1},
        async:false,
        dataType: "json",
        headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
        success: function(res){
            if(parseInt(res) === 1){
                $('#usernametishi').html('该用户名已存在!');
                $('#usernametishi').css('color','#00A8EE');
                flag = false;
                return ;
            }else{
                $('#usernametishi').html('');
                $('#usernametishi').css('color','#00A8EE');
                flag = true;
                return ;
            }
        }
    });
}
$("#btnSaveUD").click(function() {
   // alert(type);
    var username = $.trim($("#username").val());
    var sex = $("#radioGender").children('.flui_radioBox_ck').attr('value');
    var birthday = $("#OStartTime").val();
    var email = $.trim($("#email").val());
    var regex = /^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;
//	var email_l = $.trim($("#email").val());
    if(username.indexOf('毅思') > 0){
        $('#usernametishi').html('该用户名已存在!');
        $('#usernametishi').css('color','#00A8EE');
        return;
    }else if(username === '' || !(nameReg.test(username))){
        $('#usernametishi').html('请输入3~6位字符!');
        $('#usernametishi').css('color','#00A8EE');
        return ;
    }
    checkname(username);
    if(!flag){
        return;
    }
	if(email === '' || !(regex.test(email))){
        $('.j_email_l').html('请输入合法的邮箱地址!');
        $('.j_email_l').css('color','#00A8EE')
        return;
	}else{
		$('.j_email_l').html('');
	}
    var server_name  = $.trim($("#server_name").val());
    var introduction = $.trim($("#IntroductionValue").val());
    var province     = $('#province option:selected').val();
    var city         = $('#city option:selected').val();
    var country      = $('#country option:selected').val();
    if(province == ''){
        layer.tips('请选择所在地','#btnSaveUD',{time:2000});
        return;
    }
    //alert(country);
    if(username == '' || sex=='' || birthday=='' || email=='' || server_name=='' || province=='' || city=='' || country=='') {
        layer.tips('请将资料完善','#btnSaveUD',{time:2000});
        return;
    }
   
    $("#redMsg").hide();
    $.ajax({
            type: "POST",
            data: {
                username: username,
                birthday: birthday,
                server_name: server_name,
                email: email,
                sex: sex,
                introduction: introduction,
                province: province,
                city: city,
                country:country,
                type:type
            },
            url: dobaseinfo,
            headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
            dataType:'json',
            success:function(data) {
                if(data.status == 0) {
                    $("#redIntroductionMsg").hide();
                    $("#redNameMsg").hide();
                    layer.msg("设置成功！");
                    if(type == 'tiyan' || type == 'info'){
                        window.history.back();
                    }else{
                        window.location.reload();
                    }

                }else if(data.status == 2){ //申请体验账户成功，开始倒计时
                    $("#redIntroductionMsg").hide();
                    $("#redNameMsg").hide();
                    layer.msg("申请成功！");
                    $(".reg_time").hide();
                    timer=setInterval("CountDown()",1000);
                }else{
                    layer.msg("您还未登录，请先登录");
                }
            }
    })
});

$(".j_confirm").click(function() {
    var photo     = $.trim($("#photo").val());
    if(!photo){
        layer.msg('请选择您要设置的头像',{time:1000});
        return false;
    }
    $.ajax({
        url:dophoto,
        type: 'post',
        data: {'photo':photo},
        headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
        dataType:'json',
        success: function(res){
            if(res.status == 0){
                //头像设置成功
                layer.msg('头像设置成功',{time:1000});
                $('#topphoto').attr('src',photo);
                $('#topheaderphoto').attr('src',photo);
            }else if(res.status == 1){
                //用户未登录
                layer.msg("您还未登录，请先登录",{time:1000});
            }else{
                //头像设置失败
                layer.msg("设置失败",{time:1000});
            }
        }
    });
});
    

$('#OStartTime').click(function(){
	$('#laydate_box').css({'display':'block'})
})

    
    
    
})

/* 2015-05-08 基本信息 展开手机时间结束超*/
